new Vue({
	el:'#app',
	data:{
        types:[],
        states:[],
        disabled:true,
        Client_message:{
			 //客户名称
		     name:'',
			 //客户手机号
		     phone:'',
			 //客户类型
			typeId:{
				typeId:''
		    },
			 //身份证号
		    idnumber:'',
			 //身份特征
		    characteristics:'',
			 //主要负责人
		    principal:'',
			 //业务联系人
		    salesman:'',
			 //邮箱
		    mailbox:'',
			 //职务
		    duty:'',
			 //地区影响力
		    influence:'',
			 //固定电话
		    specialplane:'',
			 //所属地区
		    region:'',
			 //客户状态
			stateId:{
				stateId:''
		    },
			 //法定代表人
		    legalperson:'',
			 //法人联系方式
		    legalpersonphone:'',
			 //民族
		    nation:'',
			 //性别
		    sex:'',
			 //出生日期
		    birthdate:'',
			 //详细地址
		    site:'',
			 //备注
		    remark:''
        }
	},
	created(){
		//初始化请求得到客户类型和客户状态
		this.init();
	},
	methods:{
	  init(){
	  	this.$http.post("http://localhost:8080/client_type/listall",
	  	{emulateJSON:true}).then(result=>{
	  		var msg = eval("("+result.body+")")
			this.types = msg.data;
	  	});
	  	this.$http.post("http://localhost:8080/clientState/listall",
	  	{emulateJSON:true}).then(result=>{
	  		var msg = eval("("+result.body+")")
			this.states = msg.data;
	  	});
	  },
	  onSubmit() {
        var data = JSON.stringify(this.Client_message);
        this.$http.post("http://localhost:8080/clientMessage/insertOne",
        {"data":data},{emulateJSON:true}).then(result=>{
        	var msg = eval("("+result.body+")")
			var clientid = msg.data;
			//将委托人客户信息的id存到数据库
			localStorage.setItem("clientid", clientid);	
			this.$message.success('添加成功！~');
			this.disabled = false;
        });
      },
      next(){
      	 //跳转到下一步
      	 window.parent.parent_demo(3,"Case_add04.html");
      }
	}
});